﻿
Ext.namespace('FantastPlatform', 'FantastPlatform.UI');
FantastPlatform.UI.PatrolTaskPointGrid = function (config) {

    Ext.apply(this, config);

    var fileStore = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({
            url: '../Service/PatrolTaskPointService.aspx?Action=Search'

        }),
        reader: new Ext.data.JsonReader({
            root: 'topics',
            totalProperty: 'totalCount',
            id: 'Id',
            fields: ['Id', 'TaskName', 'PointName', 'TaskType', 'BeginTime', 'EndTime', 'DutyOrganization', 'ExecOrganization', 'PointLeader', 'TelPhone', 'PersonNum']
        }),
        remoteStore: true
    });

    this.store = fileStore;

    var paperBar = new FantastPlatform.Common.PapeToolBar({
        store: fileStore,
        noSort: true,
        defaultNum: 21
    });
    this.paperBar = paperBar;
    this.bbar = paperBar;
    this.pageNumber = paperBar.pageSize;

    var nm = new Ext.grid.RowNumberer();
    var sm = new Ext.grid.CheckboxSelectionModel();

    this.columns = [nm, sm, {
        header: 'Id',
        dataIndex: 'Id',
        hidden: true
    }, {
        header: '调警任务名称',
        width: 100,
        dataIndex: 'TaskName'
    }, {
        header: '执勤点名称',
        dataIndex: 'PointName',
        width: 110,
        sortable: true
    }, {
        header: '任务类型',
        dataIndex: 'TaskType',
        width: 110,
        sortable: true
    }, {
        header: '开始时间',
        dataIndex: 'BeginTime',
        width: 100,
        sortable: true
    }, {
        header: '结束时间',
        dataIndex: 'EndTime',
        width: 100,
        sortable: true
    }, {
        header: '牵头部门',
        dataIndex: 'DutyOrganization',
        width: 100,
        sortable: true
    }, {
        header: '执行部门',
        dataIndex: 'ExecOrganization',
        width: 200,
        sortable: true
    }, {
        header: '带队责任人',
        width: 120,
        dataIndex: 'PointLeader',
        sortable: true
    }, {
        header: '责任人电话',
        dataIndex: 'TelPhone',
        width: 100,
        sortable: true
    }, {
        header: '警力数',
        dataIndex: 'PersonNum',
        width: 100,
        sortable: true
    }];
    FantastPlatform.UI.PatrolTaskPointGrid.superclass.constructor.call(this, {
        loadMask: { msg: '正在加载数据...' },
        sm: sm
    });
}

Ext.extend(FantastPlatform.UI.PatrolTaskPointGrid, Ext.grid.GridPanel, {
    onRender: function (ct, position) {
        FantastPlatform.UI.PatrolTaskPointGrid.superclass.onRender.call(this, ct, position);
    },
    //修改
    onEditPatrolTaskPointClick: function () {
        var id = GUID();
        var node = checkGridSelected(this);
        if (node) {
            if (node.length > 1) {
                showErrorMessage("操作失败", "只能选择一条数据进行编辑", "");
            } else {
                var fId = node[0].get('Id');
                var id = GUID();

                currtWind = openWind('../PatrolTaskPointForm.aspx?Id=' + fId, id, '实名制点位', 860, 560, null);
            }
        }
    },
    onSearchClick: function () {
        var id = GUID();
        currtWind = openWind('../DirectiveSearchForm.aspx', id, '查询', 360, 190, 'new_tab');
    },
    //刷新
    onUpdataClick: function () {
        this.store.removeAll();
        this.store.proxy.conn = { method: 'post', url: this.url };
        this.store.load({ params: { start: 0, limit: this.paperBar.getPageNumber(), dir: '', sort: ''} });
    }

});